from celery import Celery
from django.conf import settings
from django.core.mail import send_mail

app = Celery('celery_tasks.tasks', broker='redis://10.2.2.184:6379/1')


@app.task
def send_register_active_email(to_email, username, token):
    subject = '欢迎您'
    message = ''
    html_message = '<h3>%s,欢迎成为爱看漫画注册用户<h3>请点击下面的链接激活账户<br/><a href="http://127.0.0.1:8000/users/active/%s">http://127.0.0.1:8000/user/active/%s' % (
        username, token, token)
    sender = settings.EMAIL_FROM
    receiver = [to_email]

    send_mail(subject, message, sender, receiver, html_message=html_message)
